--[[
	Project:		TruRP
	Author:			Martin 'Ploo' Pucilowski
	File:			commands.lua
	Date:			02/2010
	Description:	Manages commands
--]]

local ChatCommands = {}
command = {}
chatcommand = {}

function command.Add(concmd, chatcmd, callback)
	concommand.Add(concmd, callback)
	chatcommand.Add(chatcmd, callback)
end

function chatcommand.Add(cmd, callback)
	for k, v in pairs(ChatCommands) do
		if cmd == v.cmd then return end
	end
	ChatCommand = { cmd = cmd, callback = callback }
	table.insert( ChatCommands, ChatCommand )
end

function PlayerChatCommand( ply, command )
	cmd = string.lower( string.Explode(" ", command)[1], 1 )
	args = string.Explode(" ", command)
	table.remove(args, 1)
	
	print( cmd )
	PrintTable( args )
	
	for k, v in pairs(ChatCommands) do
		if v.cmd == cmd then
			v.callback( ply, cmd, args )
			break
		end
	end
end